package org.example.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.domain.Role;
import org.example.domain.RoleQuery;
import org.example.domain.bean.RestResponse;
import org.example.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "角色管理接口")
@RestController
@RequestMapping("/system/role")
public class RoleController {

    @Autowired(required = false)
    private IRoleService roleService;

    @ApiOperation("添加角色")
    @PostMapping("/role")
    public RestResponse<Integer> addNotice(@RequestBody Role role) {
        return RestResponse.success(roleService.addRole(role));
    }

    @ApiOperation("根据ids批量删除角色")
    @DeleteMapping("/role/{ids}")
    public RestResponse<Integer> removeNoticesByIds(@PathVariable("ids") List<Long> ids) {
        return RestResponse.success(roleService.removeRolesByIds(ids));
    }

    @ApiOperation("修改角色信息")
    @PutMapping("/role")
    public RestResponse<Integer> updateNotice(@RequestBody Role role) {
        return RestResponse.success(roleService.updateRole(role));
    }

    @ApiOperation("通过id获取单个角色")
    @GetMapping("/role/{id}")
    public RestResponse<Role> noticeGetById(@PathVariable("id") Long id){
        return RestResponse.success(roleService.getOneById(id));
    }

//    @ApiOperation("分页获取角色列表")
//    @PostMapping("/role/p")
//    public RestResponse<PageResponse<RoleResponse>> roleGetList(@RequestBody RoleQuery roleQuery){
//        return RestResponse.success(roleService.getListByQuery(roleQuery));
//    }
}